package com.ruoyi.manage.controller;


import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.manage.domain.BmMember;
import com.ruoyi.manage.service.BmMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商家信息1Controller
 *
 * @author ruoyi
 * @date 2022-11-07
 */
@RestController
@RequestMapping("/member")
public class BmMemberController extends BaseController {

    @Autowired
    private BmMemberService bmMemberService;

    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping("/list")
    public TableDataInfo list(BmMember bmMember) {
        System.out.println("bm" + bmMember);
        startPage();
        List<BmMember> list = bmMemberService.selectBmMemberList(bmMember);
        return getDataTable(list);
    }


    @PostMapping("/insert")
    public AjaxResult insert(BmMember bmMember) {
        System.out.println(bmMember);
        return toAjax(bmMemberService.insertBmMember(bmMember));
    }

    @PutMapping("/update")
    public AjaxResult update(BmMember bmMember) {
        return toAjax(bmMemberService.updateBmMember(bmMember));
    }

    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable("ids") String ids) {
        String[] split = ids.split(",");
        Integer[] integers = new Integer[split.length];
        for (int i = 0; i < split.length; i++) {
            int i1 = Integer.parseInt(split[i]);
            integers[i] = i1;
        }
        return toAjax(bmMemberService.deleteBmMemberByIds(integers));
    }
}

